package com.ymatou.iapi.csim.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.csim.parameter.LeaveLineBean;
import com.ymatou.iapi.csim.service.LeaveLineCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.CsimCallService;
import com.ymttest.database.model.ymt_onlinecs;
import com.ymttest.database.sqlwapper.CSIM.ymt_cssessionWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_onlinecsWapper;
import com.ymttest.database.sqlwapper.CSIM.ymt_queuesessionWapper;
import com.ymttest.utils.EnvSetup;
/**
*客服离线，不可以接收新会话
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_LeaveLine{
	private static LeaveLineBean bean;
	private static LeaveLineCall call;
	private CsimCallService service=new CsimCallService();
	private Integer csId=Integer.parseInt(EnvSetup.getData("csId").toString());
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("客服离线，不可以接收新会话");
	}

	@Before
	public void caseUp() {
		bean=new LeaveLineBean();
		call=new LeaveLineCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_LeaveLine_1() {
		Logger.start(true,"客服离线，不可以接收新会话-客服目前是在线");
		try {
			//客服上线
			ymt_onlinecs onlinecs=service.getOnlineCS(csId);
			bean.setCsId(csId);
			call.setData(bean);
			call.callService();			
			//验证
			Logger.verifyEquals("0", call.getResult().get("ErrorCode").toString(), "验证errorCode");
			Logger.verifyEquals(true, call.getResult().get("Success"), "验证Success");
			Logger.verifyEquals("200", call.getStatus(), "验证Status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_LeaveLine_2() {
		Logger.start(true,"客服离线，不可以接收新会话-客服目前是离线");
		try {
			//客服上线
			ymt_onlinecs onlinecs=service.getOnlineCS(csId);
			bean.setCsId(csId);
			call.setData(bean);
			call.callService();	
			call.callService();	
			//验证
			Logger.verifyEquals("0", call.getResult().get("ErrorCode").toString(), "验证errorCode");
			Logger.verifyEquals(true, call.getResult().get("Success"), "验证Success");
			Logger.verifyEquals("200", call.getStatus(), "验证Status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_LeaveLine_3() {
		Logger.start(true,"客服离线，不可以接收新会话-客服不存在(目前开发没有做验证)");
		try {
			//客服上线
			//ymt_onlinecs onlinecs=service.getOnlineCS(csId);
			bean.setCsId(csId+1);
			call.setData(bean);
			call.callService();	
			call.callService();	
			//验证
			Logger.verifyEquals("0", call.getResult().get("ErrorCode").toString(), "验证errorCode");
			Logger.verifyEquals(true, call.getResult().get("Success"), "验证Success");
			Logger.verifyEquals("200", call.getStatus(), "验证Status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}